package com.example.myspring.mapper;

import com.example.myspring.entity.Student;
import com.example.myspring.util.CustomSqlProvider;
import org.apache.ibatis.annotations.*;

import java.util.List;


//数据访问层
@Mapper
public interface StuDao {

    @Select("select * from student")
    List<Student> findAll();

    @Insert("insert into student (name, sex, age, address) VALUE (#{name}, #{sex}, #{age}, #{address})")
    void addStudentNotPwd(Student student);

    @SelectProvider(type = CustomSqlProvider.class, method = "countByNameOrPwd")
    int countByNameOrPwd(@Param("name") String name, @Param("password") String password);


    int updateStudent(Student student);


    //    @Insert("insert into student (name, sex, age, address,password) VALUE (#{name}, #{sex}, #{age}, #{address},md5(#{password}))")
//    void addStudent(Student student);

//    @Select("select count(*) from student where name = #{name}")
//    int countForName(String name);

//    @Select("select count(*) from student where password = MD5(#{password})")
//    int countForPwd(String pwd);
//
//    @Select("select count(*) from student where name = #{name} && password = MD5(#{pwd})")
//    int countForLogin(@Param("name") String name, @Param("pwd") String pwd);

//    @Select("select * from student where name = #{name} && password = MD5(#{pwd})")
//    Student oneStudent(@Param("name") String name, @Param("pwd") String pwd);
}
